package cn.itcast.hotel.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static cn.itcast.hotel.constant.HotelConstants.*;

@Configuration
@Slf4j
public class RabbitMqConfig {
    @Bean
    public TopicExchange bootExchange(){
        return new TopicExchange(HOTEL_EXCHANGE,true,false);
    }
    @Bean
    public Queue hotelInsertQueue(){
        return new Queue(HOTEL_INSERT_QUEUE,true);
    }
    @Bean
    public Queue hotelDeleteQueue(){
        return new Queue(HOTEL_DELETE_QUEUE,true);
    }
    @Bean
    public Binding insertBinding(){
        log.info("insertBinding绑定成功");
        return BindingBuilder.bind(hotelInsertQueue()).to(bootExchange()).with(HOTEL_INSERT_KEY);
    }
    @Bean
    public Binding deleteBinding(){
        log.info("deleteBinding绑定成功");
        return BindingBuilder.bind(hotelDeleteQueue()).to(bootExchange()).with(HOTEL_DELETE_KEY);
    }
}
